define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'bottle/collect/index',

                    table: 'bottle_collect',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'random_num', title: __('Random_num')},
                        {field: 'image', title: __('Image'), formatter: Table.api.formatter.image, operate: false},
                        {field: 'status', title: __('Status'),searchList: __('Status_s')},
                        {field: 'reamrk', title: __('Reamrk'), operate: false},
                        {field: 'create_time', title: __('Create_time'), formatter: Table.api.formatter.datetime,operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
                        {field: 'verify_time', title: __('Verify_time'), formatter: Table.api.formatter.datetime,operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [
                                {name: 'name2',
                                    text: 'Ajax',
                                    title: 'Ajax标题',
                                    icon: 'fa fa-flash',
                                    classname: 'btn btn-xs btn-success btn-ajax',
                                    url: 'bottle/collect/t_ajax',
                                    success:function(data, ret){
                                    layer.alert(ret.msg);
                                    },
                                    error:function(){}
                                },
                                {
                                    name:'name1',
                                    text:'',
                                    scrollbar: false,
                                    icon: 'fa fa-anchor',
                                    classname: 'btn btn-info btn-xs btn-dialog',
                                    url: 'bottle/collect/lists'
                                }
                            ],


                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});